/** @file
 * Declaration of rect class
 */

#ifndef WII_GI_C_RECT_H
#define WII_GI_C_RECT_H

namespace wiigi
{
   template< typename Type >
   class c_Rect
   {
      public:
         /**
          * default constructor
          */
         c_Rect( void )
         :
            m_Left(0 ),
            m_Top( 0 ),
            m_Right( 0 ),
            m_Bottom( 0 )
            
         {
            return;
         }
         
         /**
          * explicit constructor
          */
         c_Rect( Type Left, Type Top, Type Right, Type Bottom )
         :
            m_Left( Left ),
            m_Top( Top ),
            m_Right( Right ),
            m_Bottom( Bottom )
            
         {
            return;
         } 
         
          /**
           * copy constructor
           */
         c_Rect( const c_Rect& Src )
         :
            m_Left( Src.m_Left ),
            m_Top( Src.m_Top ),
            m_Right( Src.m_Right ),
            m_Bottom( Src.m_Bottom )
         {
            return;
         }
         
         void setValues( Type Left, Type Top, Type Right, Type Bottom )
         {
            m_Left   = Left;
            m_Top    = Top;
            m_Right  = Right;
            m_Bottom = Bottom;
            
            return;
         }
                  
         c_Rect& operator=( const c_Rect& Src )
         {
            setValues( Src.m_Left, Src.m_Top, Src.m_Right, Src.m_Bottom );
            
            return *this;
         }
         
         /**
          * returns width of rectangle
          * @retval Type 
          */
         Type getWidth( void )
         {
            return m_Right - m_Left;
         }
         
         /**
          * returns height of rectangle
          * @retval Type 
          */
         Type getHeight( void )
         {
            return m_Bottom - m_Top;
         }
         
         /**
          * determins if this is a valid rectanle
          */
         bool isValid( void )
         {
            if( m_Bottom <= m_Top )
            {
               return false;
            }
            
            if( m_Right <= m_Left )
            {
               return false;
            }
            
            return true;
         }
         
         void addOffset( Type X_Offset, Type Y_Offset )
         {
            m_Left   += X_Offset;
            m_Right  += X_Offset;
            m_Top    += Y_Offset;
            m_Bottom += Y_Offset;
            
            return;
         }
         
         Type getLeft( void ) const
         {
            return m_Left;
         }
         
         Type getTop( void ) const
         {
            return m_Top;
         }
         
         Type getRight( void ) const
         {
            return m_Right;
         }
         
         Type getBottom( void ) const
         {
            return m_Bottom;
         }
         
      public:
         //Data
         Type m_Left;
         Type m_Top;
         Type m_Right;
         Type m_Bottom;
      
   };
   
   typedef c_Rect< u32 > c_u32Rect;
   typedef c_Rect< f32 > c_f32Rect;
}

#endif
